home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / includ~1.z / includ~1 / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-24  |  4.6 KB  |  194 lines

  1. /*
  2.  *
  3.  *    STDIO.H        Standard i/o include file
  4.  *
  5.  */
  6.  
  7. #ifndef _STDIO_H
  8. #define    _STDIO_H
  9.  
  10. #ifndef _SIZE_T
  11. #define _SIZE_T
  12. typedef unsigned int size_t;
  13. #endif
  14.  
  15. /*
  16.  *    CONSTANTS:
  17.  */
  18. #ifndef NULL
  19. #define NULL        ((void *)0)
  20. #endif
  21. #define    NFILES        (20)        /* maximum number of open streams */
  22.  
  23. #if 0
  24. #define ATEXIT_MIN    32
  25.     /* Ansi says atleast 32 -- we make this dynamic */
  26. #endif
  27. #define    BUFSIZ        ((size_t)1024)    /* default buffer size */
  28.             /* change here must be reflected in crt0.c too */
  29.  
  30. #define    EOF        (-1)        /* end-of-file indicator */
  31. #define    EOS        '\0'        /* end-of-string indicator */
  32. #define CMASK        0377
  33.  
  34. /* lseek() origins */
  35. #define    SEEK_SET    0        /* from beginning of file */
  36. #define    SEEK_CUR    1        /* from current location */
  37. #define    SEEK_END    2        /* from end of file */
  38.  
  39. /* FILE structure flags */
  40. #define    _IOREAD        0x0001        /* file may be read from */
  41. #define    _IOWRT        0x0002        /* file may be written to */
  42. #define    _IOBIN        0x0004        /* file is in "binary" mode */
  43. #define    _IODEV        0x0008        /* file is a character device */
  44. #define    _IORW        0x0080        /* file is open for update (r+w) */
  45. #define    _IOFBF        0x0100        /* i/o is fully buffered */
  46. #define    _IOLBF        0x0200        /* i/o is line buffered */
  47. #define    _IONBF        0x0400        /* i/o is not buffered */
  48. #define    _IOMYBUF    0x0800        /* standard buffer */
  49. #define    _IOEOF        0x1000        /* EOF has been reached */
  50. #define    _IOERR        0x4000        /* an error has occured */
  51. #define _IOSTRING    0x8000        /* really a string buffer   */
  52.  
  53. typedef    struct            /* FILE structure */
  54.     {
  55.     long        _cnt;        /* # of bytes in buffer */
  56.     unsigned char    *_ptr;        /* current buffer pointer */
  57.     unsigned char    *_base;        /* base of file buffer */
  58.     unsigned int    _flag;        /* file status flags */
  59.     int        _file;        /* file handle */
  60.     long        _bsiz;        /* buffer size */
  61.     unsigned char    _ch;        /* tiny buffer, for "unbuffered" i/o */
  62.     }
  63.     FILE;
  64.  
  65. /* object of type capable of recording uniquely every position in a file */
  66. typedef unsigned long fpos_t;
  67.  
  68. #define    L_tmpnam    128
  69. #define    TMP_MAX        100
  70.  
  71. extern    FILE    _iob[];
  72.  
  73. /* standard streams */
  74. #define stdin    (&_iob[0])
  75. #define stdout    (&_iob[1])
  76. #define stderr    (&_iob[2])
  77.  
  78. /* stream macros */
  79. #define clearerr(fp)    ((void) ((fp)->_flag &= ~(_IOERR|_IOEOF)))
  80. #define feof(fp)    ((fp)->_flag & _IOEOF)
  81. #define ferror(fp)    ((fp)->_flag & _IOERR)
  82. #define fileno(fp)    ((fp)->_file)
  83.  
  84. /* aliases */
  85. #define    getc(fp)    (--(fp)->_cnt>=0? ((int)*(fp)->_ptr++):_filbuf(fp))
  86. #define    ungetc            fungetc
  87. #define    putc            fputc
  88. #define    getchar()        getc(stdin)
  89. #define    ungetchar(c)        fungetc((c),stdin)
  90. #define    putchar(c)        fputc((c),stdout)
  91.  
  92. /* function definitions */
  93. #if ((defined(__STDC__)) && (!defined(__NO_PROTO__)))
  94.  
  95. int    remove(const char *);
  96. int    rename(const char *, const char *);
  97. char    *tmpnam(char *);
  98. FILE    *tmpfile(void);
  99.  
  100. int    fclose(FILE *);
  101. int    fflush(FILE *);
  102.  
  103. FILE    *fopen(const char *, const char *);
  104. FILE    *freopen(const char *, const char *, FILE *);
  105.  
  106. void    setbuf(FILE *, char *);
  107. int    setvbuf(FILE *, char *, int, size_t);
  108.  
  109. #ifdef __SRC__
  110. int    fprintf(FILE *, const char *, int);
  111. int    printf(const char *, int);
  112. int    sprintf(char *, const char *, int);
  113. int    fscanf(FILE *, const char *, char *);
  114. int    scanf(const char *, char *);
  115. int     sscanf(const char *, const char *, int);
  116. #else
  117. int    fprintf(FILE *, const char *, ...);
  118. int    printf(const char *, ...);
  119. int    sprintf(char *, const char *, ...);
  120. int    fscanf(FILE *, const char *, ...);
  121. int    scanf(const char *, ...);
  122. int    sscanf(const char *, const char *, ...);
  123. #endif
  124.  
  125. int     vfprintf(FILE *, const char *, char *);
  126. int     vprintf(const char *, char *);
  127. int     vsprintf(char *, const char *, char *);
  128.  
  129. int    fgetc(FILE *);
  130. char    *fgets(char *, int, FILE *);
  131. char    *gets(char *);
  132. int    fputc(int c, FILE *);
  133. int    fputs(const char *, FILE *);
  134. int    puts(const char *);
  135. int     fungetc(int, FILE *);
  136.  
  137. size_t    fread(void *, size_t, size_t, FILE *);
  138. size_t    fwrite(const void *, size_t, size_t, FILE *);
  139.  
  140. int    fgetpos(FILE *, fpos_t *);
  141. int    fsetpos(FILE *, fpos_t *);
  142.  
  143. int    fseek(FILE *, long, int);
  144. long    ftell(FILE *);
  145. void    rewind(FILE *);
  146.  
  147. void    perror(const char *);
  148.  
  149. long     getl(FILE *);
  150. long     putl(long, FILE *);
  151.  
  152. int    _filbuf(FILE *);
  153.  
  154. #ifndef __STRICT_ANSI__
  155. FILE    *fdopen(int, const char *);
  156. short     getw(FILE *);
  157. short     putw(short, FILE *);
  158. FILE    *popen(const char *, const char *);
  159. int    pclose(FILE *);
  160. #endif /* __STRICT_ANSI__ */
  161.  
  162. #else
  163.  
  164. extern char    *tmpnam();
  165. extern FILE    *tmpfile();
  166.  
  167. extern FILE    *fopen();
  168. extern FILE    *freopen();
  169.  
  170. extern void    setbuf();
  171.  
  172. extern char    *fgets();
  173. extern char    *gets();
  174.  
  175. extern size_t    fread();
  176. extern size_t    fwrite();
  177.  
  178. extern long    ftell();
  179. extern void    rewind();
  180.  
  181. extern void    perror();
  182.  
  183. extern long     getl();
  184. extern long     putl();
  185.  
  186. #ifndef __STRICT_ANSI__
  187. extern FILE    *fdopen();
  188. extern FILE    *popen();
  189. #endif
  190.  
  191. #endif /* __STDC__ */
  192.  
  193. #endif /* _STDIO_H */
  194.